package com.qf.controller;

import com.qf.entity.MallGoodsBrand;
import com.qf.entity.MallGoodsCat;
import com.qf.entity.MallGoodsTemplate;
import com.qf.mapper.GoodsTemplateMapper;
import com.qf.service.IGoodsCatService;
import com.qf.service.IGoodsTemplateService;
import com.qf.vo.CatCascaderVO;
import com.qf.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>title: com.qf.controller</p>
 * <p>Company: wendao</p>
 * author zhuximing
 * date 2021/9/18
 * description:
 */
@RestController
@RequestMapping("cat")
@CrossOrigin
public class GoodsCatController {

    @Autowired
    private IGoodsCatService goodsCatService;
    @Autowired
    private GoodsTemplateMapper goodsTemplateMapper;
    @GetMapping("findByPid/{pid}")
    public List<MallGoodsCat> findByPid(@PathVariable String pid){

        return goodsCatService.selectCatListByParentId(pid);
    }

    @GetMapping("cascade")
    public List<CatCascaderVO> cascade(){

        return goodsCatService.selectCatCascade();
    }
    @RequestMapping("all")
    public List<MallGoodsTemplate> all(){

        return goodsTemplateMapper.findAll();
    }
    @RequestMapping("save")
    public Result save(@RequestBody MallGoodsCat mallGoodsCat){

        return  goodsCatService.save(mallGoodsCat);
    }
}